require 'account'
require 'digest/sha1'


# アカウント操作ヘルパ
#
# Author:: krdlab
#
# TODO 加工
# self.ticket = create_ticket
# self.expiration = 
class AccountHelper

	def initialize(cgi)
		@cgi = cgi
		@session = CGI::Session.new(cgi)
	end

	def new_account
		nil
	end

	def login
		nil
	end

	def logout
		false
	end

	def has_user?
		not @session['user'].nil?
	end

private
	def match_password(raw)
		match_password_digest(to_digest(raw))
	end

	def to_digest(raw)
		Digest::SHA1.digest(raw)
	end

	def match_password_digest(dg)
		self.password == dg
	end

	def create_ticket
		# TODO Time.now + 1h したいんだが．．．
		"hoge"
	end
end

